﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CygwinPackageManager
{
	public partial class ProgressControl : UserControl
	{
		public ProgressControl()
		{
			InitializeComponent();
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
		}

		[DefaultValue("")]
		public string Message
		{
			get { return lblMessage.Text; }
			set { lblMessage.Text = value; }
		}

		[DefaultValue(true)]
		public bool ShowLog
		{
			get { return tbLog.Visible; }
			set { tbLog.Visible = value; }
		}

		protected override void OnLayout(LayoutEventArgs e)
		{
			base.OnLayout(e);
			
			// Width.
			int availableWidth = Width;
			int totalWidth = picLoading.Width + lblMessage.Width + 5; // 5 is margin.

			picLoading.Left = availableWidth / 2 - totalWidth / 2;
			lblMessage.Left = picLoading.Right + 5; // 5 is margin.

			// Height
			int availableHeight = Height;

			picLoading.Top = availableHeight / 2 - picLoading.Height / 2;
			lblMessage.Top = availableHeight / 2 - lblMessage.Height / 2;
		}

	}
}
